<template>
  <div class="TreeSelect">
    <div class="coent" style="font-size: 18px"></div>
  </div>
</template>
<script>
import {
  ExecProcedure,
  CreateProcess,
  PlatSendTask,
  PrepareCreateProcess,
  FileServerProxy,
  sendBusinessMessage,
  QuerySignCallback,
  IfMapToApplyEdit,
  IfMapToResult
} from "../../utils/api";
export default {
  data() {
    return {
      items: [],
      ifID: "",
      TASK_ID: "",
      activeIds: [],
      activeIndex: 0,
      tableData: [],
      indexData: [],
      tableData1: [],
      code1: "",
      xcfy: "",
      rowGuid: "",
      istype: "",
    };
  },
  mounted() {
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: "选择人员",
      })
        .then((res) => {
        })
        .catch((err) => {
        });
    }
  },
  methods: {
    getData: async function (data) {
      debugger
      //先判断是不是四到场环节的请求
      if (this.$route.query.data2) {
        //农户发起四到场申请(申请页面) wjh 2022-06-10
        var newwfGuid = "";
        var ExecProParam = "";
        var IsQF = "";
        if (this.istype.isdwfy == "1") {
          //定位放养
          newwfGuid = "{612C9C60-8D18-4D23-BF32-E9D9D01BB0EA}";
          ExecProParam = 9;
          IsQF = "t";
        }
        if (this.istype.isjcyx == "1") {
          //基槽验线
          newwfGuid = "{460B4B5F-C3C2-4D4D-A702-17D4B4A3252F}";
          ExecProParam = 9;
          IsQF = "t";
        }
        if (this.istype.isyclm == "1") {
          //一层立摸
          newwfGuid = "{7F042B34-7091-4884-A5D6-A615AE55497D}";
          ExecProParam = 12;
          IsQF = "t";
        }
        if (this.istype.isjgys == "1") {
          //竣工验收
          newwfGuid = "{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}";
          ExecProParam = "";
          IsQF = "f";
        }
        //创建流程接口
        let NHApplyParam = {
          accessCode: "2c824ce489ff4cffaa0d77082e6fb648",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: {
            wfGuid: newwfGuid,
            entityRowGuid: this.istype.TASK_ID.ROW_GUID,
          },
        };
        const NHApplyresData = await FileServerProxy(NHApplyParam);

        var SendFNHApplyresData = JSON.parse(NHApplyresData.data.data);
        if(!SendFNHApplyresData.SendData){
          this.$toast.fail('创建流程失败')
          this.$router.push({
            path:'/BuildingApplication'
          })
          return
        }
        var I_ZJCITY = "";
        if (this.istype.TASK_ID.BUILDTYPE == 14) {
          I_ZJCITY = this.istype.TASK_ID.VILLAGE
        } else {
          I_ZJCITY = this.istype.TASK_ID.CUN
        }
        if (IsQF == "t") {
          let isNHApplyParam = {
            procName: "up_townaudit",
            dtParams: JSON.stringify([{ I_USERID: I_ZJCITY, I_TYPE: ExecProParam }]),
            token: window.localStorage.getItem("token"),
          };
          let xcfycjtfnApply = {
            accessCode: "69db6bece3a7480592e2ec753d1e335e",
            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: isNHApplyParam,
          };
          const resxcfycjtApply = await FileServerProxy(xcfycjtfnApply);
          var  dataxcfycjtApply = JSON.parse(resxcfycjtApply.data.data);
          if (dataxcfycjtApply.Data && dataxcfycjtApply.Data.length > 0) {
            SendFNHApplyresData.SendData.forEach((nodeItem) => {
              var maxtnid = 0; //获取tnid最大值
              if (nodeItem.PTNID == -1) {
                dataxcfycjtApply.Data.forEach((item) => {
                  var newItem = {};
                  var tnid = nodeItem.TNID;
                  maxtnid = maxtnid + 1;
                  newItem.TNID = maxtnid;
                  newItem.PTNID = tnid;
                  newItem.TEXT = item.ST_NAME;
                  newItem.USERID = item.ST_ID;
                  newItem.AUTOCHECKED = true;
                  newItem.WFNODEGUID = nodeItem.WFNODEGUID;
                  newItem.WFNODENAME = nodeItem.WFNODENAME;
                  newItem.WFNODETYPE = nodeItem.WFNODETYPE;
                  newItem.SINGLEASSIGN = nodeItem.SINGLEASSIGN;
                  newItem.ISUSER = 1;
                  this.indexData.push(newItem);
                })
              }
            })
          }
        } else {
          //竣工验收发送三个经办人
          let zjjbrex = {
            procName: "up_townaudit",
            dtParams: JSON.stringify([{ I_USERID: I_ZJCITY, I_TYPE: 13 }]),
            token: window.localStorage.getItem("token"),
          };
          let zgjbrfu = {
            accessCode: "69db6bece3a7480592e2ec753d1e335e",

            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: zjjbrex,
          };
          const reszgjbe = await FileServerProxy(zgjbrfu);
          var  datazgjbr = JSON.parse(reszgjbe.data.data);
          //规划审核经办人
          let ghjbrex = {
            procName: "up_townaudit",
            dtParams: JSON.stringify([{ I_USERID: I_ZJCITY, I_TYPE: 15 }]),
            token: window.localStorage.getItem("token"),
          };
          let ghjbrfu = {
            accessCode: "69db6bece3a7480592e2ec753d1e335e",

            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: ghjbrex,
          };
          const resghjbrbe = await FileServerProxy(ghjbrfu);
          let dataghjbr = JSON.parse(resghjbrbe.data.data);
          //农房审核经办人
          let nfjbrex = {
            procName: "up_townaudit",
            dtParams: JSON.stringify([{ I_USERID: I_ZJCITY, I_TYPE: 17 }]),
            token: window.localStorage.getItem("token"),
          };
          let nfjbrfu = {
            accessCode: "69db6bece3a7480592e2ec753d1e335e",

            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: nfjbrex,
          };
          const resnfjbrbe = await FileServerProxy(nfjbrfu);
          var  datanfjbr = JSON.parse(resnfjbrbe.data.data);
          SendFNHApplyresData.SendData.forEach((nodeItem) => {
            var maxtnid = 0; //获取tnid最大值
            var tnid = nodeItem.TNID;
            if (
              nodeItem.WFNODEGUID == "{5CC13346-8C53-4A37-989D-932716248754}" &&
              nodeItem.PTNID == -1
            ) {
              //资格经办人
              datazgjbr.Data.forEach((zgjbr) => {
                var newItem = {};
                maxtnid = maxtnid + 1;
                newItem.TNID = maxtnid;
                newItem.PTNID = tnid;
                newItem.TEXT = zgjbr.ST_NAME;
                newItem.USERID = zgjbr.ST_ID;
                newItem.AUTOCHECKED = true;
                newItem.WFNODEGUID = nodeItem.WFNODEGUID;
                newItem.WFNODENAME = nodeItem.WFNODENAME;
                newItem.WFNODETYPE = nodeItem.WFNODETYPE;
                newItem.SINGLEASSIGN = nodeItem.SINGLEASSIGN;
                newItem.ISUSER = 1;
                this.indexData.push(newItem);
              });
            }
            if (
              nodeItem.WFNODEGUID == "{74864380-8590-4F8B-BD75-942E08F04D81}" &&
              nodeItem.PTNID == -1
            ) {
              //规划经办人
              dataghjbr.Data.forEach((zgjbr) => {
                var newItem = {};
                maxtnid = maxtnid + 1;
                newItem.TNID = maxtnid;
                newItem.PTNID = tnid;
                newItem.TEXT = zgjbr.ST_NAME;
                newItem.USERID = zgjbr.ST_ID;
                newItem.AUTOCHECKED = true;
                newItem.WFNODEGUID = nodeItem.WFNODEGUID;
                newItem.WFNODENAME = nodeItem.WFNODENAME;
                newItem.WFNODETYPE = nodeItem.WFNODETYPE;
                newItem.SINGLEASSIGN = nodeItem.SINGLEASSIGN;
                newItem.ISUSER = 1;
                this.indexData.push(newItem);
              });
            }
            if (
              nodeItem.WFNODEGUID == "{7C289E35-88FC-4002-9B88-ED6F472CA872}" &&
              nodeItem.PTNID == -1
            ) {
              //农房经办人
              datanfjbr.Data.forEach((zgjbr) => {
                var newItem = {};
                maxtnid = maxtnid + 1;
                newItem.TNID = maxtnid;
                newItem.PTNID = tnid;
                newItem.TEXT = zgjbr.ST_NAME;
                newItem.USERID = zgjbr.ST_ID;
                newItem.AUTOCHECKED = true;
                newItem.WFNODEGUID = nodeItem.WFNODEGUID;
                newItem.WFNODENAME = nodeItem.WFNODENAME;
                newItem.WFNODETYPE = nodeItem.WFNODETYPE;
                newItem.SINGLEASSIGN = nodeItem.SINGLEASSIGN;
                newItem.ISUSER = 1;
                this.indexData.push(newItem);
              });
            }
          });
        }
        // //农户发起四到场申请
        this.ifID = data.WF_GUID;
        this.rowGuid = data.ROW_GUID;
        //获取人员信息并且传入到数组中只要补位-1的子集
        //村上值后调用发送接口
        this.handleGoToNext();
      }
      //农户发送
      else if (this.$route.query.data3) {
        //wjh 2022-05-24 lc提供新的存储过程，旧的注释
        ;
        //获取人员
        let paramss = {
          accessCode: "0a709d649c314903a72225edb8bc8c2a",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: {
            taskId: data.TASK_ID,
            direction: 0, //0是发送  1是打回
            token: window.localStorage.getItem("token"),
          },
        };
        const resdata3 = await FileServerProxy(paramss);
        var SendFormData3 = JSON.parse(resdata3.data.data);
        //调用存储过程
        var IsQF = "";
        var I_ZJCITY = "";
        if (
          this.$route.query.data.TASK_ID &&
          this.$route.query.data.TASK_ID.BUILDTYPE == 14
        ) {
          I_ZJCITY = this.$route.query.data.TASK_ID.SSZZ;
        } else {
          I_ZJCITY = this.$route.query.data.TASK_ID.TOWN;
        }
        var I_TYPE = "";
        if (
          this.$route.query.I_TYPE &&
          (this.$route.query.I_TYPE == "2" || this.$route.query.I_TYPE == "11")
        ) {
          I_TYPE = 9;
          IsQF = "t";
        } else if (
          this.$route.query.I_TYPE &&
          (this.$route.query.I_TYPE == "21" || this.$route.query.I_TYPE == "12")
        ) {
          //基槽沿
          I_TYPE = 11;
          IsQF = "t";
        } else if (
          this.$route.query.I_TYPE &&
          (this.$route.query.I_TYPE == "22" || this.$route.query.I_TYPE == "13")
        ) {
          I_TYPE = 12;
          IsQF = "t";
        } else if (
          this.$route.query.I_TYPE &&
          this.$route.query.I_TYPE == "23"
        ) {
          //验收
          I_TYPE = 13;
          IsQF = "f";
        }

        if (IsQF == "t") {
          let xcfycjtex = {
            procName: "up_townaudit",
            dtParams: JSON.stringify([{ I_USERID: I_ZJCITY, I_TYPE: I_TYPE }]),
            token: window.localStorage.getItem("token"),
          };
          let xcfycjtfn = {
            accessCode: "69db6bece3a7480592e2ec753d1e335e",

            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: xcfycjtex,
          };
          const resxcfycjt = await FileServerProxy(xcfycjtfn);
          let dataxcfycjt = JSON.parse(resxcfycjt.data.data);
          if (dataxcfycjt.Data && dataxcfycjt.Data.length > 0) {
            dataxcfycjt.Data.forEach((item) => {
              SendFormData3.SendData.forEach((nodeItem) => {
                var maxtnid = 0; //获取tnid最大值
                if (nodeItem.PTNID != -1) {
                  var newItem = {};
                  var tnid = nodeItem.TNID;
                  maxtnid = maxtnid + 1;
                  newItem.TNID = maxtnid;
                  newItem.PTNID = tnid;
                  newItem.TEXT = item.ST_NAME;
                  newItem.USERID = item.ST_ID;
                  newItem.AUTOCHECKED = true;
                  newItem.WFNODEGUID = nodeItem.WFNODEGUID;
                  newItem.WFNODENAME = nodeItem.WFNODENAME;
                  newItem.WFNODETYPE = nodeItem.WFNODETYPE;
                  newItem.SINGLEASSIGN = nodeItem.SINGLEASSIGN;
                  newItem.ISUSER = 1;
                  this.indexData.push(newItem);
                  //this.indexData.push(ArraynewItem);
                }
              });
            });
          }
        } else {
          //竣工验收
          //资格经办人 调用存储过程获资格经办人

          let zjjbrex = {
            procName: "up_townaudit",
            dtParams: JSON.stringify([{ I_USERID: I_ZJCITY, I_TYPE: 13 }]),
            token: window.localStorage.getItem("token"),
          };
          let zgjbrfu = {
            accessCode: "69db6bece3a7480592e2ec753d1e335e",

            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: zjjbrex,
          };
          const reszgjbe = await FileServerProxy(zgjbrfu);
          let datazgjbr = JSON.parse(reszgjbe.data.data);
          //规划审核经办人
          let ghjbrex = {
            procName: "up_townaudit",
            dtParams: JSON.stringify([{ I_USERID: I_ZJCITY, I_TYPE: 15 }]),
            token: window.localStorage.getItem("token"),
          };
          let ghjbrfu = {
            accessCode: "69db6bece3a7480592e2ec753d1e335e",

            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: ghjbrex,
          };
          const resghjbrbe = await FileServerProxy(ghjbrfu);
          let dataghjbr = JSON.parse(resghjbrbe.data.data);
          //农房审核经办人
          let nfjbrex = {
            procName: "up_townaudit",
            dtParams: JSON.stringify([{ I_USERID: I_ZJCITY, I_TYPE: 17 }]),
            token: window.localStorage.getItem("token"),
          };
          let nfjbrfu = {
            accessCode: "69db6bece3a7480592e2ec753d1e335e",

            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: nfjbrex,
          };
          const resnfjbrbe = await FileServerProxy(nfjbrfu);
          let datanfjbr = JSON.parse(resnfjbrbe.data.data);
          SendFormData3.SendData.forEach((nodeItem) => {
            var maxtnid = 0; //获取tnid最大值
            var tnid = nodeItem.TNID;
            if (
              nodeItem.WFNODEGUID == "{5CC13346-8C53-4A37-989D-932716248754}" &&
              nodeItem.PTNID == -1
            ) {
              //资格经办人
              datazgjbr.Data.forEach((zgjbr) => {
                var newItem = {};
                maxtnid = maxtnid + 1;
                newItem.TNID = maxtnid;
                newItem.PTNID = tnid;
                newItem.TEXT = zgjbr.ST_NAME;
                newItem.USERID = zgjbr.ST_ID;
                newItem.AUTOCHECKED = true;
                newItem.WFNODEGUID = nodeItem.WFNODEGUID;
                newItem.WFNODENAME = nodeItem.WFNODENAME;
                newItem.WFNODETYPE = nodeItem.WFNODETYPE;
                newItem.SINGLEASSIGN = nodeItem.SINGLEASSIGN;
                newItem.ISUSER = 1;
                this.indexData.push(newItem);
              });
            }
            if (
              nodeItem.WFNODEGUID == "{74864380-8590-4F8B-BD75-942E08F04D81}" &&
              nodeItem.PTNID == -1
            ) {
              //规划经办人
              dataghjbr.Data.forEach((zgjbr) => {
                var newItem = {};
                maxtnid = maxtnid + 1;
                newItem.TNID = maxtnid;
                newItem.PTNID = tnid;
                newItem.TEXT = zgjbr.ST_NAME;
                newItem.USERID = zgjbr.ST_ID;
                newItem.AUTOCHECKED = true;
                newItem.WFNODEGUID = nodeItem.WFNODEGUID;
                newItem.WFNODENAME = nodeItem.WFNODENAME;
                newItem.WFNODETYPE = nodeItem.WFNODETYPE;
                newItem.SINGLEASSIGN = nodeItem.SINGLEASSIGN;
                newItem.ISUSER = 1;
                this.indexData.push(newItem);
              });
            }
            if (
              nodeItem.WFNODEGUID == "{7C289E35-88FC-4002-9B88-ED6F472CA872}" &&
              nodeItem.PTNID == -1
            ) {
              //农房经办人
              datanfjbr.Data.forEach((zgjbr) => {
                var newItem = {};
                maxtnid = maxtnid + 1;
                newItem.TNID = maxtnid;
                newItem.PTNID = tnid;
                newItem.TEXT = zgjbr.ST_NAME;
                newItem.USERID = zgjbr.ST_ID;
                newItem.AUTOCHECKED = true;
                newItem.WFNODEGUID = nodeItem.WFNODEGUID;
                newItem.WFNODENAME = nodeItem.WFNODENAME;
                newItem.WFNODETYPE = nodeItem.WFNODETYPE;
                newItem.SINGLEASSIGN = nodeItem.SINGLEASSIGN;
                newItem.ISUSER = 1;
                this.indexData.push(newItem);
              });
            }
          });
        }
        this.handleGoToNext();
      }
       else {
        //获取人员
        if (this.$route.query.data3) {
          var I_USERID = "";
          let paramsData = {};
          paramsData.procName = "up_SFZHUSER";
          var CW = data.CWID;
          var NH = data.CERTIFICATECODE;
          var DBRSFZH = data.DBRSFZH;
          // I_USERID = CW + "," + NH + "," + DBRSFZH;
          if ((DBRSFZH ? (DBRSFZH.toString().substr(DBRSFZH.length - 1, 1)) : "") == "X" || (NH ? (NH.toString().substr(NH.length - 1, 1)) : "") == "X") {
            I_USERID = "'" + CW + "'" + "," + "'" + NH + "'" + "," + "'" + DBRSFZH + "'";
          } else {
            I_USERID = CW + "," + NH + "," + DBRSFZH;
          }
          paramsData.dtParams = JSON.stringify([{ I_USERID: I_USERID }]);
          paramsData.token = window.localStorage.getItem("token");
          let paer = {
            accessCode: "69db6bece3a7480592e2ec753d1e335e",
            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: paramsData,
          };
          const req = await FileServerProxy(paer);
          var data1 = JSON.parse(req.data.data).Data;
        } else {
          let params = {
            accessCode: "0a709d649c314903a72225edb8bc8c2a",
            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: {
              taskId: data.TASK_ID,
              direction: 0,
              token: window.localStorage.getItem("token"),
            },
          };
          const res = await FileServerProxy(params);
          var data1 = JSON.parse(res.data.data);
        }
        if (data1.SendData && data1.SendData.length > 1) {
          if (this.$route.query.I_TYPE) {
          } else {
            //调用存储过程
            var USERID = "";
            let paramsData = {};
            // 农户危房申请阶段
            if (
              this.$route.query.data.TASK_ID.NODE_GUID ===
              "{5E869057-F0CA-4E87-80D4-9B7FECEAFE9E}"
            ) {
              USERID = data.JDJGID;
              paramsData.procName = "up_processusername";
              paramsData.dtParams = JSON.stringify([
                { I_USERID: USERID, TYPE: 4 },
              ]);
            } else {
              paramsData.procName = "USERNAME";
              var CW = data.CWID;
              var NH = data.NHID;
              USERID = CW + "," + NH;
              paramsData.dtParams = JSON.stringify([{ I_USERID: USERID }]);
            }
            paramsData.token = window.localStorage.getItem("token");
            let paer = {
              // procName: "USERNAME",
              // dtParams: JSON.stringify([{ I_USERID: USERID }]),
              accessCode: "69db6bece3a7480592e2ec753d1e335e",
              cityCode: window.localStorage.getItem("citycode")
                ? window.localStorage.getItem("citycode")
                : "441300000000",
              params: paramsData,
              // "params": {
              //   "procName": "USERNAME",
              //   "dtParams": JSON.stringify([{ I_USERID: USERID }]),
              //   "token": window.localStorage.getItem("token"),
              // }
            };

            const req = await FileServerProxy(paer);
            var reqData = JSON.parse(req.data.data);
          }
          if (data1.SendData) {
            data1.SendData.forEach((item) => {
              if (item.PTNID == -1) {
                this.tableData.push(item);
              }
            });
          }
          reqData.Data.forEach((j) => {
            var nodeItem; //获取修改的流程节点对象
            var maxtnid; //获取tnid最大值
            for (var i = 0; i < this.tableData.length; i++) {
              let item = this.tableData[i];
              var curTnid = item.TNID;
              if (!maxtnid) {
                maxtnid = curTnid;
              } else if (curTnid > maxtnid) {
                maxtnid = curTnid;
              }
            }
            var tnid = this.tableData[0].TNID;
            var newItem = {};
            maxtnid = i + 1;
            newItem.TNID = maxtnid;
            newItem.PTNID = tnid;
            newItem.TEXT = j.USERNAME;
            newItem.USERID = j.USERID;
            newItem.AUTOCHECKED = "";
            newItem.WFNODEGUID = this.tableData[0].WFNODEGUID;
            newItem.WFNODENAME = this.tableData[0].WFNODENAME;
            newItem.WFNODETYPE = this.tableData[0].WFNODETYPE;
            newItem.SINGLEASSIGN = this.tableData[0].SINGLEASSIGN;
            newItem.ISUSER = 1;
            this.tableData.push(newItem);
          });
          this.indexData = this.tableData;
        } else {
          data1.forEach((j, index) => {
            var nodeItem; //获取修改的流程节点对象
            var maxtnid; //获取tnid最大值
            for (var i = 0; i < this.tableData.length; i++) {
              let item = this.tableData[i];
              var curTnid = item.TNID;
              if (!maxtnid) {
                maxtnid = curTnid;
              } else if (curTnid > maxtnid) {
                maxtnid = curTnid;
              }
            }
            var tnid = 1;
            var newItem = {};
            maxtnid = i + 1;
            newItem.TNID = 768 + index;
            newItem.PTNID = tnid;
            newItem.TEXT = j.USERNAME;
            newItem.USERID = j.USERID;
            newItem.AUTOCHECKED = "";
            newItem.WFNODEGUID = this.$route.query.data.TASK_ID.NODE_GUID;
            newItem.WFNODENAME = this.$route.query.data.TASK_ID.NODE_NAME;
            newItem.WFNODETYPE = this.$route.query.data.TASK_ID.NODE_TYPE;
            // newItem.SINGLEASSIGN = this.tableData[0].SINGLEASSIGN;
            newItem.ISUSER = 1;
            this.tableData.push(newItem);
          });
          this.indexData = this.tableData;
          // this.indexData = data1;
        }
        this.ifID = data.WF_GUID;
        this.rowGuid = data.ROW_GUID;
        //获取人员信息并且传入到数组中只要补位-1的子集
        //村上值后调用发送接口
        this.handleGoToNext();
      }
    },
    onClickLeft() {
      this.$router.back(-1);
    },
    handleGoToNext: async function () {
      //判断当前是否选择了人员
      if (this.$route.query.data2) {
        if (this.indexData.length > 0) {
          //创建流程WorkFlowServer/api/CreateProcess
          let params1 = {
            bizGuid: "",
            wfGuid: this.xcfy,
            entityRowGuid: this.rowGuid,
          };
          let params = {
            accessCode: "3ec88931e2bf429d9ceadff8697b6772",
            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: params1,
          };
          const resCreate = await FileServerProxy(params);
          // const resCreate = await CreateProcess(params);
          var resCreateData = JSON.parse(resCreate.data.data);
          if (resCreate && resCreateData) {
            let plantask = {
              taskId: resCreateData.TaskId,
              direction: 0,
              wfBoxGuid: "",
              actionText: "",
              taskName: "",
              wfGuid: this.xcfy,
              sendNodes: JSON.stringify(this.indexData),
            };
            let params = {
              accessCode: "c52bcf7cf3fb42bb9fbcd9b91e97d411",
              cityCode: window.localStorage.getItem("citycode")
                ? window.localStorage.getItem("citycode")
                : "441300000000",
              params: plantask,
            };
            const respl = await FileServerProxy(params);
            if (respl) {
              this.$toast.success("成功");
              // this.$notify({ type: "success", message: "成功！！！" });
              setTimeout(() => {
                this.$router.push({
                  path: '/ZLJIndex',
                });
              }, 500);
            }
          }
        } else {
          this.$toast.fail("请选择人员");
          // this.$notify({ type: "danger", message: "请选择人员！！！" });
        }
      } else {
        ;
        if (this.indexData.length > 0) {
          if (this.$route.query.data.TASK_ID) {
            let plantask = {
              // taskId: resCreateData.TaskId,
              // direction: 0,
              // wfBoxGuid: "",
              // actionText: "",
              // taskName: "",
              // wfGuid: this.xcfy,
              // sendNodes: JSON.stringify(this.indexData),
              accessCode: "c52bcf7cf3fb42bb9fbcd9b91e97d411",
              cityCode: window.localStorage.getItem("citycode")
                ? window.localStorage.getItem("citycode")
                : "441300000000",
              params: {
                taskId: this.$route.query.data.TASK_ID.TASK_ID,
                direction: 0,
                wfBoxGuid: "",
                actionText: "同意",
                taskName: "",
                wfGuid: this.xcfy,
                sendNodes: JSON.stringify(this.indexData),
                token: window.localStorage.getItem("token"),
              },
            };
            const respl = await FileServerProxy(plantask);
            // const respl = await PlatSendTask(plantask);
            let data = JSON.parse(respl.data.data).Success;
            // JSON.parse(resCreate.data.data)
            if (data) {
              this.$toast.success("成功！");
              setTimeout(() => {
                this.$router.push({
                  path: '/ZLJIndex',
                });
              }, 500);
            }
          }
        } else {
          this.$toast.fail("请选择人员！");
          // this.$notify({ type: "danger", message: "请选择人员！" });
        }
      }

      //发送后调用方法修改状态
      if (
        this.$route.query.data.TASK_ID.NODE_GUID ==
        "{D2048C7B-88F9-453C-8FB9-6CFBE287634F}" ||
        this.$route.query.data.TASK_ID.NODE_GUID ==
        "{E359B708-D4B2-426F-BA00-45C5E94B6D7D}" ||
        this.$route.query.data.TASK_ID.NODE_GUID ==
        "{757359B4-6AC2-4860-899F-94A348EC0177}" ||
        this.$route.query.data.TASK_ID.NODE_GUID ==
        "{576D4397-9795-4DA1-87CA-3B22A90D71B8}" ||
        this.$route.query.data.TASK_ID.NODE_GUID ==
        "{B3ACD6E6-CD10-42B4-9C36-B981DA0129E4}" ||
        this.$route.query.data.TASK_ID.NODE_GUID ==
        "{DD6E6B1C-BD45-4E2B-9086-FB533FAAC3B5}" ||
        this.$route.query.data.TASK_ID.NODE_GUID ==
        "{924CF865-825F-4257-9C64-BE2533B8C99B}"
      ) {
        let Itype = "";
        if (
          this.$route.query.data.TASK_ID.NODE_GUID ==
          "{D2048C7B-88F9-453C-8FB9-6CFBE287634F}"
        ) {
          Itype = 11;
        }
        if (
          this.$route.query.data.TASK_ID.NODE_GUID ==
          "{757359B4-6AC2-4860-899F-94A348EC0177}"
        ) {
          Itype = 12;
        }
        if (
          this.$route.query.data.TASK_ID.NODE_GUID ==
          "{E359B708-D4B2-426F-BA00-45C5E94B6D7D}"
        ) {
          Itype = 2;
        }
        if (
          this.$route.query.data.TASK_ID.NODE_GUID ==
          "{576D4397-9795-4DA1-87CA-3B22A90D71B8}"
        ) {
          Itype = 21;
        }
        if (
          this.$route.query.data.TASK_ID.NODE_GUID ==
          "{B3ACD6E6-CD10-42B4-9C36-B981DA0129E4}"
        ) {
          Itype = 13;
        }
        if (
          this.$route.query.data.TASK_ID.NODE_GUID ==
          "{DD6E6B1C-BD45-4E2B-9086-FB533FAAC3B5}"
        ) {
          Itype = 22;
        }
        if (
          this.$route.query.data.TASK_ID.NODE_GUID ==
          "{924CF865-825F-4257-9C64-BE2533B8C99B}"
        ) {
          Itype = 23;
        }
        // let str = this.$route.query.data.ZCITY;
        let paerEx = {
          procName: "cs_xgnhfsh",
          dtParams: JSON.stringify([
            {
              I_PROC_GUID: this.$route.query.data.TASK_ID.PROC_GUID,
              I_TYPE: Itype,
              I_ROW_GUID: this.$route.query.data.TASK_ID.ROW_GUID,
              I_PKID: this.$route.query.data.TASK_ID.PKID,
            },
          ]),
          token: window.localStorage.getItem("token"),
        };
        let procNamesEX = {
          accessCode: "69db6bece3a7480592e2ec753d1e335e",

          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: paerEx,
        };
        const resEX = await FileServerProxy(procNamesEX);
      }
      debugger
      //wjh 2023/3/21修改地图状态
      if(this.istype.isdwfy == "1" || this.istype.isjcyx == "1" || this.istype.isyclm == "1" || this.istype.isjgys == "1"){
         this.ifMapApplyEdit();
      }
      //发送短信
      if (
        (this.$route.query &&
          (this.$route.query.data.isjcyx == "1" ||
            this.$route.query.data.isyclm == "1" ||
            this.$route.query.data.isjgys == "1" ||
            this.$route.query.data.isdwfy == "1")) ||
        this.istype
      ) {
        //现场放养申请
        //调用存储过程获取人员手机号
        ;
        var temp = "";
        var strMessqge =
          this.$route.query.data.TASK_ID.CWID +
          "," +
          this.$route.query.data.TASK_ID.NHID;
        let paerssend = {
          procName: "message",
          dtParams: JSON.stringify([{ I_USERID: strMessqge, I_TYPE: 3 }]),
          token: window.localStorage.getItem("token"),
        };
        let paramsendMEssage = {
          accessCode: "69db6bece3a7480592e2ec753d1e335e",

          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: paerssend,
        };
        const reqwmsg = await QuerySignCallback(paramsendMEssage);
        const JSONSend = JSON.parse(reqwmsg.data.data);
        if (this.istype.isdwfy == "1") {
          temp = "9a891424f9884d75b19163a95d8a5094";
        }
        if (this.istype.isjcyx == "1") {
          //基槽验线
          temp = "81b96d82b66f413589b7d9572fa9e708";
        }
        if (this.istype.isyclm == "1") {
          //一层立磨
          temp = "443c9167bbf24a8d81fb0707e3f207ea";
        }
        if (this.istype.isjgys == "1") {
          //竣工验收
          temp = "05cf2dc7667e4a478a3d377b8e0dcddc";
        }
        if (JSONSend && JSONSend.Data && JSONSend.Data.length > 0) {
          JSONSend.Data.forEach((phone) => {
            let paramdf = {
              mobiles: phone.MOBILETEL,
              templateId: temp,

              accessCode: "11b5cfe531954d94bb924c856e63a99b",
            };
            // 发送短信通知
            sendBusinessMessage(paramdf);
          });
        }
      }
    },
     //wjh 2023/3/21  四到场修改审批状态
      //修改上图状态
    ifMapApplyEdit:async function(){
      var  type="";
      var  spzt="";
      try
      {
        //现场放样
        if(this.istype.isdwfy == "1"){
          type="XCFY";
          spzt="SPWC";
        }
        //基槽验线
        if(this.istype.isjcyx == "1"){
          type="JCYX";
          spzt="SPWC";
        }
        //一层立模
        if(this.istype.isyclm == "1"){
          type="YCLM";
          spzt="SPWC";
        }
        //竣工验收
        if(this.istype.isjgys == "1"){
          type="JGYS";
          spzt="SPWC";
        }
        var parameters = {
          f: "json",
          outFields: "*",
          where: `sqbh='${this.$route.query.data.TASK_ID.ROW_GUID}'`,
         };
        var   result=  await IfMapToResult(parameters);
        if(result&&result.data&&result.data.features&&result.data.features.length>0){
          var  formData=new  FormData();
          formData.append("updates",JSON.stringify([{ "attributes": { "objectid": result.data.features[0].attributes.objectid,  "stagetype": type,"SPZT":spzt}}]));
          formData.append("f","json");
          await  IfMapToApplyEdit(formData);
        }
        else {
        //   this.$toast.fail('未上传标绘图层')
          return  false;
        }
      }catch(e){

      }
    },

  },
  mounted() {
    //接收浙里办传来的参数
    ;
    if (
      this.$route.query &&
      this.$route.query.data &&
      (this.$route.query.data.isdwfy ||
        this.$route.query.data.isjcyx ||
        this.$route.query.data.isyclm ||
        this.$route.query.data.isjgys)
    ) {
      this.istype = this.$route.query.data;
    }
    if (
      this.$route.query.data.TASK_ID.NODE_GUID ==
      "{F81FCB82-7196-4E94-BFF5-159E1CEBEFF8}" ||
      this.$route.query.data.TASK_ID.NODE_GUID ==
      "{576D4397-9795-4DA1-87CA-3B22A90D71B8}"
    ) {
      //基槽验线
      this.xcfy = "{460B4B5F-C3C2-4D4D-A702-17D4B4A3252F}";
    } else if (
      this.$route.query.data.TASK_ID.NODE_GUID ==
      "{FEF0E7B0-F048-42E0-998E-06387B0D03DB}" ||
      this.$route.query.data.TASK_ID.NODE_GUID ==
      "{FAFEF7FF-6294-489A-A5DF-53906712EBEE}" ||
      this.$route.query.data.TASK_ID.NODE_GUID ==
      "{E359B708-D4B2-426F-BA00-45C5E94B6D7D}" ||
      this.$route.query.data.TASK_ID.NODE_GUID =="{E349B5CD-E963-4A17-ABE4-258EF79C55F2}"
    ) {
      //现场放杨
      this.xcfy = "{612C9C60-8D18-4D23-BF32-E9D9D01BB0EA}";
    } else if (
      this.$route.query.data.TASK_ID.NODE_GUID ==
      "{10BAEA52-EDDE-48C7-97AD-C211D272010E}" ||
      this.$route.query.data.TASK_ID.NODE_GUID ==
      "{DD6E6B1C-BD45-4E2B-9086-FB533FAAC3B5}"
    ) {
      //一层立模
      this.xcfy = "{7F042B34-7091-4884-A5D6-A615AE55497D}";
    } else if (
      this.$route.query.data.TASK_ID.NODE_GUID ==
      "{C89D1E12-1303-482F-BB9E-45457905C759}"
    ) {
      //竣工验收
      this.xcfy = "{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}";
    } else if (
      this.$route.query.data.TASK_ID.NODE_GUID ==
      "{5E869057-F0CA-4E87-80D4-9B7FECEAFE9E}" ||
      this.$route.query.data.TASK_ID.NODE_GUID ==
      "{924CF865-825F-4257-9C64-BE2533B8C99B}"
    ) {
      //农户危改申请
      this.xcfy = "{DF6C42D5-2BED-473B-9C4D-DA8C42DAF7E9}";
    }
    this.getData(this.$route.query.data.TASK_ID);
    //调用视图减少人员选择
  },
};
</script>
<style lang="scss" scoped>
.TreeSelect {
  height: 100vh;
  background: #fff;
  font-size: 0.2em;
}
</style>
